package com.bthdung.studios.lesson12;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import com.bthdung.studios.R;

/*
 * Tạo một splash screen với time delay là 4s. hiển thị một số thông tin cơ bản.
 * */
public class SplashActivity extends Activity {
	int splashTime = 4000;
	int reqCode = 5;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.main12);

		Timer t = new Timer(true);
		TimerTask task = new TimerTask() {
			@Override
			public void run() {
				Intent intent = new Intent(getBaseContext(),
						RenderActivity.class);
				startActivityForResult(intent, reqCode);
			}
		};

		t.schedule(task, splashTime);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (requestCode == reqCode) {
			System.gc();
			finish();
		}
	}
}